
<%@page import="com.sinba.common.user.dto.RegUserBasicDTO"%>
<%@page import="com.sinba.common.user.service.IRegisterUserService"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="../language.jsp" %>

<%
if(session.getAttribute("password2")==null){
	response.sendRedirect( "login2.jsp?pageUrl=user/pi.jsp");
	return;
}

ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
IRegisterUserService registerUserService = (IRegisterUserService)ac.getBean("registerUserService");
RegUserBasicDTO rubDTO = registerUserService.findRegUserBasicInfo((String)session.getAttribute("loginName"));
request.setAttribute("rubDTO",rubDTO);
session.setAttribute("end", "修改资料");
session.setAttribute("middle", "个人管理");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><fmt:message key="i18n.userInfo"/>-<fmt:message key="i18n.title"/></title>
<link rel="shortcut icon" href="../index/favicon.png" />
<jsp:include page="common.jsp"></jsp:include>
</head>
<body>
	<jsp:include page="page_head.jsp"></jsp:include>
	
	<div class="row">
		<div class="col-md-12">
			<div class="box border primary">
				<div class="box-title">
					<h4><i class="fa fa-bars"></i><fmt:message key="i18n.userInfo"/></h4>
					<div class="tools hidden-xs">
						<a href="#box-config" data-toggle="modal" class="config">
							<i class="fa fa-cog"></i>
						</a>
						<a href="javascript:;" class="reload">
							<i class="fa fa-refresh"></i>
						</a>
						<a href="javascript:;" class="collapse">
							<i class="fa fa-chevron-up"></i>
						</a>
						<a href="javascript:;" class="remove">
							<i class="fa fa-times"></i>
						</a>
					</div>
				</div>
				<div class="box-body big">
					<h3 class="form-title"><fmt:message key="i18n.updateUserInfo"/></h3>
					<form class="form-horizontal" role="form" id="updateInfo_form" action="registerUser!changeRegUserBasicInfo.action" method="post" onsubmit="return changeBasicInfo();">
						<input type="hidden" name="rubDTO.loginName" value="${rubDTO.loginName }" />
				       	<input type="hidden" type="hidden" name="rubDTO.registerUserId" value="${rubDTO.registerUserId }" />
				       	<input type="hidden" name="rubDTO.qq" value="${rubDTO.qq }" />
				       	<input type="hidden" name="rubDTO.email" value="${rubDTO.email }" />
				       	<!-- <input type="hidden" id="pi_loginUser_authCodeType" name="rubDTO.authCodeType"/> -->
				       	<input type="hidden"  name="pageUrl" value="pi.jsp" />
					  <div class="form-group">
						<label class="col-sm-3 control-label"><fmt:message key="i18n.piUserName"/>：</label>
						<div class="col-sm-9">
						  <input type="text" class="form-control" placeholder="<fmt:message key="i18n.piUserName"/>" 
						  name="rubDTO.userName" id="pi_userName" value="${rubDTO.userName }">
						</div>
					  </div>
					   <div class="form-group">
							<label class="col-sm-3 control-label"><fmt:message key="i18n.openUserBank"/>：</label>
							<div class="col-sm-9">
							 <select class="form-control" id="accountType" name="rubDTO.accountType" >
							    <option value="中国农业银行" <c:if test="${rubDTO.accountType eq '中国农业银行' }">selected</c:if>><fmt:message key="i18n.abcBank"/></option>
								<option value="中国工商银行" <c:if test="${rubDTO.accountType eq '中国工商银行' }">selected</c:if>><fmt:message key="i18n.gongBank"/></option>
								<option value="中国建设银行" <c:if test="${rubDTO.accountType eq '中国建设银行' }">selected</c:if>><fmt:message key="i18n.ccbBank"/></option>
								<option value="中国银行" <c:if test="${rubDTO.accountType eq '中国银行' }">selected</c:if>><fmt:message key="i18n.chinaBank"/></option>
								<option value="财付通" <c:if test="${rubDTO.accountType eq '财付通' }">selected</c:if>><fmt:message key="i18n.caifutong"/></option>
								<option value="支付宝" <c:if test="${rubDTO.accountType eq '支付宝' }">selected</c:if>>支付宝</option>
							</select>
						  </div>
					  </div>
					  <div class="form-group">
						<label class="col-sm-3 control-label"><fmt:message key="i18n.piBrankAccount"/>：</label>
						<div class="col-sm-9">
						  <input type="text"  name="rubDTO.bankAccount" required="true" value="${rubDTO.bankAccount }" class="form-control" placeholder="<fmt:message key="i18n.piBrankAccount"/>">
						</div>
					  </div>
					  
					   <div class="form-group">
						<label class="col-sm-3 control-label"><fmt:message key="i18n.openBankAddress"/>：</label>
						<div class="col-sm-9">
						  <input type="text" name="rubDTO.openBankAddress" required="true" value="${rubDTO.openBankAddress }"  class="form-control" placeholder="<fmt:message key="i18n.openBankAddress"/>">
						</div>
					  </div>
					  
					   <div class="form-group">
						<label class="col-sm-3 control-label">手机号码：</label>
						<div class="col-sm-9">
							<input type="hidden" id="cp_loginUserMobile" name="rubDTO.mobile" value="${rubDTO.mobile}" />
						  <input type="text" name="rubDTO.newMobile" readonly="readonly" id="cp_loginUserMobile_new" value="${rubDTO.mobile}" class="form-control" placeholder="手机号码">
						</div>
					  </div>
					  
					  <div class="form-group">
						<label class="col-sm-3 control-label">手机验证码：</label>
						<div class="col-sm-6">
						 	<input class="form-control col-sm-5" id="cp_validCode" name="rubDTO.authCode" >
						</div>
						<div class="col-sm-3">
							<input type="button" class="form-control col-sm-4" id="cp_loginName_button" 
								value="<fmt:message key="i18n.getVerificationCode"/>" /> 
							<input type="hidden" value="${session.email }" id="cp_loginName"/>
						</div>
					  </div>
					  
					   <div class="form-group">
						<label class="col-sm-3 control-label">手机号码：</label>
						<div class="col-sm-9">
							<input type="hidden" id="cp_loginUserMobile" name="rubDTO.mobile" value="${rubDTO.mobile}" />
						  <input type="text" name="rubDTO.newMobile" readonly="readonly" id="cp_loginUserMobile_new" value="${rubDTO.mobile}" class="form-control" placeholder="手机号码">
						</div>
					  </div>
					  	<div class="form-group">
						<label class="col-sm-3 control-label"></label>
						<div class="col-sm-9">
						  <c:if test="${not empty session.activationTime}">
						  	<button type="submit" class="btn btn-primary" style="width:15em;"><fmt:message key="i18n.update"/></button>
							</c:if>
							<c:if test="${empty session.activationTime}">
							未激活（如需激活请联系注册时填写的运营中心）
							</c:if>
						</div>
					  </div>
					 </form>
				</div>
			</div>
		</div>
	</div>	
	
	<jsp:include page="page_foot.jsp"></jsp:include>
</body>
<script src="../scripts/user/common.js"></script>
<script type="text/javascript">

function changeBasicInfo(){
	if($('#pi_userName').val()==''){
		alert('姓名不能为空!');
		$('#pi_userName').focus();
		return false;
	}
	
	if($('#pi_email').val()==''){
		alert('邮件地址不能为空!');
		$('#pi_email').focus();
		return false;
	}
	
	if($('#pi_passwordAnswer').val()==''){
		alert('密保答案不允许为空!');
		$('#pi_passwordAnswer').focus();
		return false;
	}
	
	if($('#cp_validCode').val()==''){
		alert('验证码不能为空!');
		$('#cp_validCode').focus();
		return false;
	}
/* 	
	$.post('activationCode!authEmailCode.action','dto.type=邮件&dto.category=UpdateUser&dto.activationCode='+$('#pi_validCode').val(),function(res){
		 if(!res){
			 alert('E-mail verification code is not correct(邮箱验证码不正确)!');
			 return false;
		 }else{
			 $('#updateInfo_form').submit();
		 }
	}); */
}

$(function(){
	document.onkeydown = function(evt){
		var evt = window.event?window.event:evt;
		if(evt.keyCode==13){
			changeBasicInfo();
		}
	}
	$("#cp_loginName_button").click(function(){
		if($("#cp_loginUserMobile").val() && $("#cp_loginUserMobile").val().length > 0){
			getVerificationCode('Mobile','ChangeInfo','#cp_loginUserMobile','#cp_loginName_button');
		}else if($("#cp_loginName").val() && $("#cp_loginName").val().length > 0){
			getVerificationCode('Email','ChangeInfo','#cp_loginName','#cp_loginName_button');
		}else{
			alert('未找到有效邮箱或者手机号码，无法进行验证!');
		}
	});
});
</script>

</html>